package com.ybxx.base.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;

import com.ybxx.base.model.FeesType;
import com.ybxx.base.service.FeesTypeService;
import com.ybxx.core.command.QueryFilter;
import com.ybxx.core.util.UUIDGenerator;
import com.ybxx.core.web.action.BaseAction;

public class FeesTypeAction extends BaseAction {
	@Resource
	private FeesTypeService feesTypeService;
	private FeesType feesType;
	private List<FeesType> feesTypes;
	private String msg="succ";
	/*删除*/
	public String remove(){
		try{
			feesTypeService.remove(feesType.getFtid());
		}catch(Exception ex){
			msg="卫生分项删除失败";
		}finally{
			return "succ";
		}
	}
	/*加载查看时候需要展示的数据*/
	public String view(){
		if(feesType!=null && StringUtils.isNotEmpty(feesType.getFtid())){
			feesType=feesTypeService.get(feesType.getFtid());
		}
		return "view";
	}
	public String queryPage(){
		QueryFilter filter=new QueryFilter(getRequest());
		feesTypes=feesTypeService.queryPage(feesType,filter);
		super.setRownum(filter.getPagingBean().getTotalItems());
		super.setCurrentpage(Integer.parseInt(filter.getPagingBean().getStart()+"")/Integer.parseInt(filter.getPagingBean().getPageSize()+"")+1);
		super.setPageSize(Integer.parseInt(filter.getPagingBean().getPageSize()+""));
		return "queryPage";
	}
	/*保存新增，修改信息*/
	public String save(){
		if(StringUtils.isEmpty(feesType.getFtid())){
			feesType.setFtid(UUIDGenerator.getUUID());
		}
		try{
			feesTypeService.save(feesType);
		}catch(Exception ex){
			msg="卫生费分项保存失败.";
		}finally{
			return "succ";
		}
	}
	/*加载修改时候需要展示的数据*/
	public String load(){
		if(feesType!=null && StringUtils.isNotEmpty(feesType.getFtid())){
			feesType=feesTypeService.get(feesType.getFtid());
		}
		return "load";
	}
	public FeesType getFeesType() {
		return feesType;
	}
	public void setFeesType(FeesType feesType) {
		this.feesType = feesType;
	}
	public List<FeesType> getFeesTypes() {
		return feesTypes;
	}
	public void setFeesTypes(List<FeesType> feesTypes) {
		this.feesTypes = feesTypes;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
}
